Component({
  data: {
    show: false,
    t: null,
    baseOptions: {
      icon: 'loading',
      text: '数据加载中...',
      delay: 1200
    },
    options: {
      icon: 'loading',
      text: '数据加载中...',
      delay: 1200
    }
  },
  methods: {
    show() {
      const that = this;
      this.setData({ show: true });
    },  
    hide() {  //  关闭弹窗 重置数据
      const that = this;
      this.setData({ show: false });

      //  避免未关闭弹窗就替换数据了
      setTimeout(() => {
        this.setData({ options: that.data.baseOptions })
      }, 500);
    },
    auto(options = {}) {
      const origin = this.data.options;
      this.setData({ options: Object.assign(origin, options) });
      //  开启弹窗
      this.show();
      this.data.t = setTimeout(() => {
        //  关闭弹窗
        this.hide();
      }, origin.delay);
    }
  }
});